package com.pug.product.rest;

import com.alibaba.fastjson.JSON;
import com.pug.product.service.IInventoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xq.pug.common.result.R;
import xq.pug.feign.dto.product.DedInventoryFeignReqDTO;

/**
 * @program: xq_pug_alibabacloud_parent
 * @description:
 * @author: Mr.Ren
 * @create: 2023-07-02 21:46
 **/
@RestController
@RequestMapping("/inventory")
@Slf4j
public class InventoryController {

    @Autowired
    private IInventoryService inventoryService;

    @PostMapping("/ded")
    public R<Integer> dedInventory(@RequestBody DedInventoryFeignReqDTO reqDTO){
        log.info("dedInventory接口，请求参数【{}】", JSON.toJSONString(reqDTO));
        int i = inventoryService.dedInventory(reqDTO.getProductCode(),reqDTO.getDedCount());
        log.info("dedInventory接口，响应参数【{}】", i);
        return R.ofSuccess(i);
    }
}
